using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using OpenComposite.EII.Repository;
using OpenComposite.Repository.Properties;

namespace OpenComposite.EII.RepositoryUIs
{
	public partial class UCDiagram : RepositoryItemUI
	{
		#region Initialization

		public UCDiagram(IServiceProvider serviceProvider)
			: base(serviceProvider)
		{
			InitializeComponent();
		}

		#endregion

		#region Public Members

		#region Properties
		public override IRepositoryItem RepositoryItem
		{
			get
			{
				save();
				return _diagram;
			}
			set
			{
				if ( value is Diagram ) {
					_diagram = (Diagram)value;
					load();
				}
			}
		}

		public override string TypeText
		{
			get { return Resources.sDiagram; }
		}

		public override string TypeDescription
		{
			get { return ""; }
		}
		#endregion

		#region Events
		#endregion

		#region Methods
		#endregion

		#endregion

		#region Private Members

		#region Variables
		private Diagram _diagram = null;
		#endregion

		#region Methods
		private void load()
		{
			if ( _diagram == null )
				return;

			txtName.Text = _diagram.Name;
			txtDesc.Text = _diagram.Description;
		}
		private void save()
		{
			if ( _diagram == null )
				_diagram = new Diagram();

			_diagram.Reload();

			_diagram.Name = txtName.Text;
			_diagram.Description = txtDesc.Text;
		}
		#endregion

		#region Event Handlers
		#endregion

		#endregion
	}
}
